package hied.testing;

import hied.Example;
import hied.ExampleList;
import hied.Knowledge;
import hied.cleaning.Cleaner;

import java.io.File;

import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.core.Persister;

public class TestingApplication {
	public static void main(String[] args) throws Exception {
		Serializer serializer = new Persister();
		File source = new File("test.xml");
		ExampleList testSet = serializer.read(ExampleList.class, source);
		source = new File("knowledge.xml");
		Knowledge knowlegde = serializer.read(Knowledge.class, source);
		Cleaner cleaner = new Cleaner(knowlegde);

		int all = 0;
		int success = 0;
		for (Example test : testSet.getExamples()) {
			String cleaned = cleaner.clean(test.getBefore());
			all++;
			if (!cleaned.equals(test.getAfter())) {
				System.out
						.println(test.getBefore() + " ->\t" + cleaned + " <>\t" + test.getAfter());
			} else {
				success++;
			}
		}
		System.out.println("successed: " + success + "/" + all);
	}
}
